﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FrienDev.BusinessRules;
using FrienDev.Data;

public partial class Controls_Activity_ImageEdit : System.Web.UI.UserControl
{
    private int m_activityId,m_imageId;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request.QueryString["activityid"]) && !string.IsNullOrEmpty(Request.QueryString["imageid"]))
        {
            m_activityId = Convert.ToInt32(Request.QueryString["activityid"]);
            m_imageId = Convert.ToInt32(Request.QueryString["imageid"]);
            bt_Edit.Click += new EventHandler(bt_Edit_Click);
            hl_AllImage.NavigateUrl = "~/Activity/ImageListDetail.aspx?activityid=" + m_activityId; 
            Photo curPhoto=PhotoRules.Instance.GetPhotoInfoById(m_imageId);
            img_ActivityImage.ImageUrl = PhotoRules.Instance.GetActivitySmallPhotoUrl(m_activityId,curPhoto.FileName);
            if (!IsPostBack)
            {
                txt_Description.Text = curPhoto.Description;
            }
        }
    }

    void bt_Edit_Click(object sender, EventArgs e)
    {
        PhotoRules.Instance.UpdatePhotoDescription(m_imageId, txt_Description.Text.Trim());
        Response.Redirect("~/Activity/ImageListDetail.aspx?activityid=" + m_activityId);
    }
}
